package com.xmx.confu_work.common.vo;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @Author: DingZhen
 * @Data:2024-04-23 09:28
 * 工具类，返回json数据
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class Result<T> {
    private Integer code;
    private String massage;
    private T data;

    //功能执行成功
    public static <T> Result<T> success(){
        return new Result<>(20000,"success",null);
    }

    public static <T> Result<T> success(T data){
        return new Result<>(20000,"success",data);
    }

    public static <T> Result<T> success(T data,String message){
        return new Result<>(20000,message,data);
    }

    public static <T> Result<T> success(String message){
        return new Result<>(20000,message,null);
    }

    //功能执行失败
    public static <T> Result<T> faid(){
        return new Result<>(20001,"faid",null);
    }

    public static <T> Result<T> faid(Integer code){
        return new Result<>(code,"faid",null);
    }

    public static <T> Result<T> faid(Integer code,String message){
        return new Result<>(code,message,null);
    }

    public static <T> Result<T> faid(String message){
        return new Result<>(20001,message,null);
    }
}
